<?php
class Application_Model_Remittance extends Application_Model_DomainObject{
	
	protected $_id;
	
	protected $_bankCard;      //汇款方账号
	
	protected $_realName;      //汇款方姓名
        
        protected $_dealNo;         //交易流水号

        protected $_money;        //汇款金额
        
        protected $_moneyUnit;    //金额单位 

        protected $_bank;          //汇款银行
        
        protected $_dateCreated;    //提交时间

        protected $_picture;       //汇款凭证

        protected $_userId;        //用户Id
        
        protected $_transferTime;     //汇款时间
        
        protected $_isDelete;         //标记删除
        
        protected $_status;           //状态
        
        protected $_type;            //类型    0银行转账  1西联汇款
        
        /**
         * 未处理
         */
        const STATUS_UNTREATED = 0;
        
        /**
         * 已处理
         */
        const STATUS_PROCESSED = 1; 
        /**
         * 人民币
         */
        const Unit_CNY = 1;
        /**
         * 美元
         */
        const Unit_USD = 2;
        /**
         * 马来西亚元
         */
        const Unit_MYR = 3; 

        public static function getMyByFilter($search,$pagesize,$start){
//            var_dump($search->getSearchFileds());
            return self::getDao()->queryPage($search->getSearchFileds(), " id desc ", $pagesize, $start);
        }
        
        /**
        * 根据userid，加载user对象
        * @author wuzw
        * @return type
        */
        public function getuserinfo() {
            if ($this->_userId) {
                return Application_Model_User::load($this->_userId);
            }
        }
        
        /**
         * @return 银行汇款未处理的记录个数
         */
        public static function getTransferCount(){
            $where = array();
            $where['status = 0 and (isDelete is null or isDelete = 0) and '] = 1;
            return self::getDao()->count($where);
        }
        
        public static function arrUnitAll()
        {
            return array(
                       self::Unit_CNY => "CNY(人民币)"
                    ,  self::Unit_USD => "USD(美元)"
                    ,  self::Unit_MYR => "MYR(马来西亚元)"
            );
        }
        
        public function getUnitName()
        {
            $arrUnit = self::arrUnitAll();
            return $arrUnit[$this->_moneyUnit];
        }
        
        public static function getByDealNo($dealNo)
        {
            return self::getDao()->queryOne(array(" (isDelete is null or isDelete = "=>0," ) and dealNo = "=>$dealNo));
        }
}
